<template>
	<view class="ljapp reportpage">
		<view class="content">
			<view class="card" :class="item.status" v-for="(item,index) in group.list" :key="index">
				<view class="head u-flex u-flex-between">
					<view style="width: 500rpx;">解读报告—<text>{{item.report_filename}}</text></view>
					<view class="status">{{item.typename}}</view>
				</view>
				<view class="con u-flex">
					<image class="avatar" :src="$base.cdn(item.user_headimgurl)" mode="aspectFill"></image>
					<view class="u-flex-fill u-flex u-flex-items-end">
						<view class="info u-flex-fill">
							<view class="u-flex u-flex-items-end">
								<view>{{item.user_the_patient_info?item.user_the_patient_info.name:'--'}}</view>
								<view class="sex">{{item.user_the_patient_info?(item.user_the_patient_info.sex == '1' ? '男' : '女'):'--'}}</view>
								<view class="age">{{item.user_the_patient_info?item.user_the_patient_info.age:'--'}}岁</view>
							</view>
							<view class="sn">订单号：{{item.order_code}}</view>
							<view class="time">日期：{{$u.timeFormat(item.createtime,'yyyy/mm/dd hh:MM')}}</view>
						</view>
						<view class="btn-report" @click="Onjump(item)">解读记录</view>
					</view>
				</view>
			</view>

			<lj-empty v-if="group.loaded&&group.list.length<=0">暂无订单</lj-empty>
			<view v-else>
				<u-loadmore
					:status="loading?'loading':(group.loaded?'nomore':'loadmore')"
					fontSize="28rpx"
					color="#d9d9d9"
					nomoreText="已加载全部"
					marginTop="30rpx"
					marginBottom="0"
					@loadmore="getList"
				></u-loadmore>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				group:{
					page: 1,
					limit: 10,
					list: [],
					loaded: false
				},
				loading: false,
			}
		},
		onLoad() {},
		onShow(){
			this.init()
		},
		methods: {
			init(){
				this.group.page = 1
				this.group.list = []
				this.group.loaded = false
				this.loading = false

				this.getList();
			},
			getList(){
				var that = this,group = that.group;
				if(that.loading || group.loaded) return;

				that.loading = true

				this.$Http({
					url: 'doctorlistConsultationReportOrder',
					data: {
						page: group.page,
						limit: group.limit,
					},
					type:'POST',
				}).then(res=>{
					if(res.code == 1){
						var list = res.data.data;
						group.loaded = list.length < group.limit;
						group.page ++;

						list.forEach(item => {
							if(item.user_the_patient_info) item.user_the_patient_info.age = this.$base.Onage(item.user_the_patient_info.birthday)

							if (item.pay_status == 2) {
								if (item.status == 'normal') {
									item.typename = '待支付'
								}
								if (item.status == 'cancel') {
									item.typename = '已取消'
								}
								item.status_is = false
							}
							if (item.pay_status == 1) {
								item.status_is = true
								if (item.status == 'normal') {
									item.typename = '待接诊'
									if(item.no_patient_timing <= 0){
										item.typename = '已退款'
										item.status_is = false
									}
								}
								if (item.status == 'refund') {
									item.typename = '已退款'
									item.status_is = false
								}
								if (item.status == 'refuse_patient') {
									item.typename = '拒绝接诊'
								}
								if (item.status == 'patient') {
									item.typename = '进行中'
								}
								if (item.status == 'end') {
									item.typename = '已结束'
								}
								if (item.status == 'comment') {
									item.typename = '已评价'
								}
							}
						})

						group.list = group.list.concat(list);
					}

					that.loading = false
				}).catch(()=>{
					that.loading = false
				});
			},
			onReachBottom(){
				this.getList()
			},
			Onjump(e) {
				uni.navigateTo({
					url: '/pagesA/message/chat?isDoc=1&cate=report&orderno='+e.order_code
				})
			}
		}
	}
</script>

<style lang="less">
	@import '@/pagesD/style.less';
</style>
